package com.crm.config;
import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.authc.credential.SimpleCredentialsMatcher;

/**
 * 验证登录的密码
 * @author 周远星
 *
 */
public class CredentialMatcher extends SimpleCredentialsMatcher {

    @Override
    public boolean doCredentialsMatch(AuthenticationToken token, AuthenticationInfo info) {
        
    	UsernamePasswordToken usernamePasswordToken = (UsernamePasswordToken) token;
    	//用户输入的密码
    	String password = new String(usernamePasswordToken.getPassword());
    	//数据库读取的用户名
    	String dbPassword = (String) info.getCredentials();
        return this.equals(password, dbPassword);
    }
}
